<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: NicEntryDebug Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00161.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-types">Protected Types</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">NicEntryDebug Class Reference<div class="ingroups"><a class="el" href="a00517.html">connectionManager - channel and connection related classes</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="NicEntryDebug" --><!-- doxytag: inherits="NicEntry" -->
<p><a class="el" href="a00159.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntry</a> is used by <a class="el" href="a00052.html" title="BaseConnectionManager implementation which only defines a specific max interference distance...">ConnectionManager</a> to store the necessary information for each nic.  
 <a href="a00161.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00252_source.html">NicEntryDebug.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for NicEntryDebug:</div>
<div class="dyncontent">
<div class="center"><img src="a00909.png" border="0" usemap="#NicEntryDebug_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for NicEntryDebug:</div>
<div class="dyncontent">
<div class="center"><img src="a00910.png" border="0" usemap="#NicEntryDebug_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00911.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8a318f2611c8fcf9a495525a910f40b6"></a><!-- doxytag: member="NicEntryDebug::NicEntryDebug" ref="a8a318f2611c8fcf9a495525a910f40b6" args="(bool debug)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#a8a318f2611c8fcf9a495525a910f40b6">NicEntryDebug</a> (bool debug)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor, initializes all members. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a23514a51dfbdba46bf20b2f005a34214"></a><!-- doxytag: member="NicEntryDebug::~NicEntryDebug" ref="a23514a51dfbdba46bf20b2f005a34214" args="()" -->
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#a23514a51dfbdba46bf20b2f005a34214">~NicEntryDebug</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Removes all dynamically created out-/ingates. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#af97ebc8c81c1f7d8094344d2f7fb6a17">connectTo</a> (<a class="el" href="a00159.html">NicEntry</a> *other)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Connect two nics.  <a href="#af97ebc8c81c1f7d8094344d2f7fb6a17"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#a837ccd605ce3df345fcf3f5787673fac">disconnectFrom</a> (<a class="el" href="a00159.html">NicEntry</a> *other)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Disconnect two nics.  <a href="#a837ccd605ce3df345fcf3f5787673fac"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-types"></a>
Protected Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acb03289d82cdd4035567f3fbc8117105"></a><!-- doxytag: member="NicEntryDebug::GateStack" ref="acb03289d82cdd4035567f3fbc8117105" args="" -->
typedef std::vector&lt; cGate * &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>GateStack</b></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">cGate *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#aa028678e801ba669ad47a6588b2ad90a">requestInGate</a> (void)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a free in gate of the nic.  <a href="#aa028678e801ba669ad47a6588b2ad90a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">cGate *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#ad601c375fa2fd737f88b3a475a06ff45">requestOutGate</a> (void)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a free out gate of the nic.  <a href="#ad601c375fa2fd737f88b3a475a06ff45"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#ae4c6e480d8b2f3fc4199a7a8314ab2df">collectGates</a> (const char *pattern, GateStack &amp;gates)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Collects all free gates with a certain pattern as names and puts them on a stack.  <a href="#ae4c6e480d8b2f3fc4199a7a8314ab2df"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#aac3b943e56b211541596a73f6437608a">collectFreeGates</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Iterates over all existing gates of this NicEntries nic and host and checks wether they are useable by this nic entry.  <a href="#aac3b943e56b211541596a73f6437608a"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac676487d56ac68916121ce8e52465205"></a><!-- doxytag: member="NicEntryDebug::inCnt" ref="ac676487d56ac68916121ce8e52465205" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#ac676487d56ac68916121ce8e52465205">inCnt</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of in gates allocated for the nic so far. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af1bf7c23c872e6838f8111cf58e4839e"></a><!-- doxytag: member="NicEntryDebug::outCnt" ref="af1bf7c23c872e6838f8111cf58e4839e" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#af1bf7c23c872e6838f8111cf58e4839e">outCnt</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of out gates allocated for the nic so far. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#a2aa0dd90daecf5469bc9c8b53b21579c">checkFreeGates</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Check for unknown free gates before next gate request.  <a href="#a2aa0dd90daecf5469bc9c8b53b21579c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae2e64139016744d1c8a59c4d9f6b009f"></a><!-- doxytag: member="NicEntryDebug::freeInGates" ref="ae2e64139016744d1c8a59c4d9f6b009f" args="" -->
GateStack&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f">freeInGates</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">In Gates that were once used but are not connected now. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0564884c56d1bcda68b8797a5bd60af0"></a><!-- doxytag: member="NicEntryDebug::freeOutGates" ref="a0564884c56d1bcda68b8797a5bd60af0" args="" -->
GateStack&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0">freeOutGates</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Out Gates that were once used but are not connected now. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p><a class="el" href="a00159.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntry</a> is used by <a class="el" href="a00052.html" title="BaseConnectionManager implementation which only defines a specific max interference distance...">ConnectionManager</a> to store the necessary information for each nic. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Daniel Willkomm </dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00052.html" title="BaseConnectionManager implementation which only defines a specific max interference distance...">ConnectionManager</a>, <a class="el" href="a00159.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntry</a> </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aac3b943e56b211541596a73f6437608a"></a><!-- doxytag: member="NicEntryDebug::collectFreeGates" ref="aac3b943e56b211541596a73f6437608a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void NicEntryDebug::collectFreeGates </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Iterates over all existing gates of this NicEntries nic and host and checks wether they are useable by this nic entry. </p>
<p>This method is necessary if a nic was unregistered from its connection manager during a simulation and is then again registered with one. When unregistered the gates created by this <a class="el" href="a00161.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntryDebug</a> are not deleted so they can be collected and reused again when the nic is registered again. </p>

<p>References <a class="el" href="a00161.html#a2aa0dd90daecf5469bc9c8b53b21579c">checkFreeGates</a>, <a class="el" href="a00161.html#ae4c6e480d8b2f3fc4199a7a8314ab2df">collectGates()</a>, <a class="el" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f">freeInGates</a>, <a class="el" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0">freeOutGates</a>, <a class="el" href="a00161.html#ac676487d56ac68916121ce8e52465205">inCnt</a>, and <a class="el" href="a00161.html#af1bf7c23c872e6838f8111cf58e4839e">outCnt</a>.</p>

<p>Referenced by <a class="el" href="a00161.html#aa028678e801ba669ad47a6588b2ad90a">requestInGate()</a>, and <a class="el" href="a00161.html#ad601c375fa2fd737f88b3a475a06ff45">requestOutGate()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="keywordflow">if</span>(!<a class="code" href="a00161.html#a2aa0dd90daecf5469bc9c8b53b21579c" title="Check for unknown free gates before next gate request.">checkFreeGates</a>)
    <span class="keywordflow">return</span>;

  <a class="code" href="a00161.html#ac676487d56ac68916121ce8e52465205" title="Number of in gates allocated for the nic so far.">inCnt</a> = <a class="code" href="a00161.html#ae4c6e480d8b2f3fc4199a7a8314ab2df" title="Collects all free gates with a certain pattern as names and puts them on a stack.">collectGates</a>(<span class="stringliteral">&quot;in%d-%d&quot;</span>, <a class="code" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f" title="In Gates that were once used but are not connected now.">freeInGates</a>);
  nicEV &lt;&lt; <span class="stringliteral">&quot;found &quot;</span> &lt;&lt; <a class="code" href="a00161.html#ac676487d56ac68916121ce8e52465205" title="Number of in gates allocated for the nic so far.">inCnt</a> &lt;&lt; <span class="stringliteral">&quot; already existing usable in-gates.&quot;</span> &lt;&lt; endl;

  <a class="code" href="a00161.html#af1bf7c23c872e6838f8111cf58e4839e" title="Number of out gates allocated for the nic so far.">outCnt</a> = <a class="code" href="a00161.html#ae4c6e480d8b2f3fc4199a7a8314ab2df" title="Collects all free gates with a certain pattern as names and puts them on a stack.">collectGates</a>(<span class="stringliteral">&quot;out%d-%d&quot;</span>, <a class="code" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0" title="Out Gates that were once used but are not connected now.">freeOutGates</a>);
  nicEV &lt;&lt; <span class="stringliteral">&quot;found &quot;</span> &lt;&lt; <a class="code" href="a00161.html#ac676487d56ac68916121ce8e52465205" title="Number of in gates allocated for the nic so far.">inCnt</a> &lt;&lt; <span class="stringliteral">&quot; already existing usable out-gates.&quot;</span> &lt;&lt; endl;

  <a class="code" href="a00161.html#a2aa0dd90daecf5469bc9c8b53b21579c" title="Check for unknown free gates before next gate request.">checkFreeGates</a> = <span class="keyword">false</span>;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ae4c6e480d8b2f3fc4199a7a8314ab2df"></a><!-- doxytag: member="NicEntryDebug::collectGates" ref="ae4c6e480d8b2f3fc4199a7a8314ab2df" args="(const char *pattern, GateStack &amp;gates)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int NicEntryDebug::collectGates </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>pattern</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">GateStack &amp;&#160;</td>
          <td class="paramname"><em>gates</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Collects all free gates with a certain pattern as names and puts them on a stack. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">pattern</td><td>The naming pattern of the gates, something like "out%d-%d" where the first d is filled with the nic id and the second with an incrementing counter. </td></tr>
    <tr><td class="paramname">gates</td><td>The gate stack in which to put the found gates. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the number of free gates found. </dd></dl>

<p>References <a class="el" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109">NicEntry::nicId</a>, and <a class="el" href="a00159.html#af7819e950101d5062b713eb4c182e34f">NicEntry::nicPtr</a>.</p>

<p>Referenced by <a class="el" href="a00161.html#aac3b943e56b211541596a73f6437608a">collectFreeGates()</a>.</p>
<div class="fragment"><pre class="fragment">{
  cModule* host = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;&gt;::findHost</a>(<a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>);
  <span class="keywordtype">int</span> i = 1;
  <span class="keywordtype">char</span> gateName[20];
  <span class="comment">//create the unique name for the gate (composed of the nic module id and a counter)</span>
  sprintf(gateName, pattern, <a class="code" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109" title="module id of the nic for which information is stored">nicId</a>, i);
  <span class="keywordflow">while</span>(host-&gt;hasGate(gateName))
  {
    cGate* hostGate = host-&gt;gate(gateName);
    <span class="keywordflow">if</span>(hostGate-&gt;isConnectedOutside()) {
      opp_error(<span class="stringliteral">&quot;Gate %s is still connected but not registered with this &quot;</span>
            <span class="stringliteral">&quot;NicEntry. Either the last NicEntry for this NIC did not &quot;</span>
            <span class="stringliteral">&quot;clean up correctly or another gate creation module is &quot;</span>
            <span class="stringliteral">&quot;interfering with this one!&quot;</span>, gateName);
    }
    assert(hostGate-&gt;isConnectedInside());
    gates.push_back(hostGate);

    ++i;
    sprintf(gateName, pattern, <a class="code" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109" title="module id of the nic for which information is stored">nicId</a>, i);
  }

  <span class="keywordflow">return</span> i - 1;
}
</pre></div>
</div>
</div>
<a class="anchor" id="af97ebc8c81c1f7d8094344d2f7fb6a17"></a><!-- doxytag: member="NicEntryDebug::connectTo" ref="af97ebc8c81c1f7d8094344d2f7fb6a17" args="(NicEntry *other)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void NicEntryDebug::connectTo </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00159.html">NicEntry</a> *&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Connect two nics. </p>
<p>Establish unidirectional connection with other nic</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">other</td><td>reference to remote nic (other <a class="el" href="a00159.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntry</a>)</td></tr>
  </table>
  </dd>
</dl>
<p>This function acquires an in gate at the remote nic and an out gate at this nic, connects the two and updates the freeInGate, freeOutGate and outConns data sets. </p>

<p>Implements <a class="el" href="a00159.html#a32a71bf1823d8ca0d51fd1cbb67072fe">NicEntry</a>.</p>

<p>References <a class="el" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109">NicEntry::nicId</a>, <a class="el" href="a00159.html#a66b957327e66c042028f7b38e4bd0b46">NicEntry::outConns</a>, <a class="el" href="a00161.html#aa028678e801ba669ad47a6588b2ad90a">requestInGate()</a>, and <a class="el" href="a00161.html#ad601c375fa2fd737f88b3a475a06ff45">requestOutGate()</a>.</p>
<div class="fragment"><pre class="fragment">{
  nicEV&lt;&lt;<span class="stringliteral">&quot;connecting nic #&quot;</span>&lt;&lt;<a class="code" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109" title="module id of the nic for which information is stored">nicId</a>&lt;&lt; <span class="stringliteral">&quot; and #&quot;</span>&lt;&lt;other-&gt;<a class="code" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109" title="module id of the nic for which information is stored">nicId</a>&lt;&lt;endl;

  <a class="code" href="a00161.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntryDebug</a>* otherNic = (<a class="code" href="a00161.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntryDebug</a>*) other;

  cGate *localoutgate = <a class="code" href="a00161.html#ad601c375fa2fd737f88b3a475a06ff45" title="Returns a free out gate of the nic.">requestOutGate</a>();
  localoutgate-&gt;connectTo(otherNic-&gt;<a class="code" href="a00161.html#aa028678e801ba669ad47a6588b2ad90a" title="Returns a free in gate of the nic.">requestInGate</a>());
  <a class="code" href="a00159.html#a66b957327e66c042028f7b38e4bd0b46" title="Outgoing connections of this nic.">outConns</a>[other] = localoutgate-&gt;getPathStartGate();
}
</pre></div>
</div>
</div>
<a class="anchor" id="a837ccd605ce3df345fcf3f5787673fac"></a><!-- doxytag: member="NicEntryDebug::disconnectFrom" ref="a837ccd605ce3df345fcf3f5787673fac" args="(NicEntry *other)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void NicEntryDebug::disconnectFrom </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00159.html">NicEntry</a> *&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Disconnect two nics. </p>
<p>Release unidirectional connection with other nic</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">other</td><td>reference to remote nic (other <a class="el" href="a00159.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntry</a>) </td></tr>
  </table>
  </dd>
</dl>

<p>Implements <a class="el" href="a00159.html#a0cce4edbe3eb6036ded986482de3de48">NicEntry</a>.</p>

<p>References <a class="el" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f">freeInGates</a>, <a class="el" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0">freeOutGates</a>, <a class="el" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109">NicEntry::nicId</a>, and <a class="el" href="a00159.html#a66b957327e66c042028f7b38e4bd0b46">NicEntry::outConns</a>.</p>

<p>Referenced by <a class="el" href="a00161.html#a23514a51dfbdba46bf20b2f005a34214">~NicEntryDebug()</a>.</p>
<div class="fragment"><pre class="fragment">{
  nicEV&lt;&lt;<span class="stringliteral">&quot;disconnecting nic #&quot;</span>&lt;&lt;<a class="code" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109" title="module id of the nic for which information is stored">nicId</a>&lt;&lt; <span class="stringliteral">&quot; and #&quot;</span>&lt;&lt;other-&gt;<a class="code" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109" title="module id of the nic for which information is stored">nicId</a>&lt;&lt;endl;

  <a class="code" href="a00161.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntryDebug</a>* otherNic = (<a class="code" href="a00161.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntryDebug</a>*) other;

  <span class="comment">//search the connection in the outConns list</span>
  GateList::iterator p = <a class="code" href="a00159.html#a66b957327e66c042028f7b38e4bd0b46" title="Outgoing connections of this nic.">outConns</a>.find(other);
  <span class="comment">//no need to check whether entry is valid; is already check by ConnectionManager isConnected</span>
  <span class="comment">//get the hostGate</span>
  <span class="comment">//order is phyGate-&gt;nicGate-&gt;hostGate</span>
  cGate* hostGate = p-&gt;second-&gt;getNextGate()-&gt;getNextGate();

  <span class="comment">// release local out gate</span>
  <a class="code" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0" title="Out Gates that were once used but are not connected now.">freeOutGates</a>.push_back(hostGate);

  <span class="comment">// release remote in gate</span>
  otherNic-&gt;<a class="code" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f" title="In Gates that were once used but are not connected now.">freeInGates</a>.push_back(hostGate-&gt;getNextGate());

  <span class="comment">//reset gates</span>
  <span class="comment">//hostGate-&gt;getNextGate()-&gt;connectTo(0);</span>
  hostGate-&gt;disconnect();

  <span class="comment">//delete the connection</span>
  <a class="code" href="a00159.html#a66b957327e66c042028f7b38e4bd0b46" title="Outgoing connections of this nic.">outConns</a>.erase(p);
}
</pre></div>
</div>
</div>
<a class="anchor" id="aa028678e801ba669ad47a6588b2ad90a"></a><!-- doxytag: member="NicEntryDebug::requestInGate" ref="aa028678e801ba669ad47a6588b2ad90a" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cGate * NicEntryDebug::requestInGate </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns a free in gate of the nic. </p>
<p>This checks the list of free in gates, if one is available it is returned. Otherwise, a new in gate is added to the nic. </p>

<p>References <a class="el" href="a00161.html#aac3b943e56b211541596a73f6437608a">collectFreeGates()</a>, <a class="el" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f">freeInGates</a>, <a class="el" href="a00161.html#ac676487d56ac68916121ce8e52465205">inCnt</a>, <a class="el" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109">NicEntry::nicId</a>, and <a class="el" href="a00159.html#af7819e950101d5062b713eb4c182e34f">NicEntry::nicPtr</a>.</p>

<p>Referenced by <a class="el" href="a00161.html#af97ebc8c81c1f7d8094344d2f7fb6a17">connectTo()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <a class="code" href="a00161.html#aac3b943e56b211541596a73f6437608a" title="Iterates over all existing gates of this NicEntries nic and host and checks wether they are useable b...">collectFreeGates</a>();

  <span class="comment">// gate of the host</span>
  cGate *hostGate;

  <span class="keywordflow">if</span> (!<a class="code" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f" title="In Gates that were once used but are not connected now.">freeInGates</a>.empty()) {
    hostGate = <a class="code" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f" title="In Gates that were once used but are not connected now.">freeInGates</a>.back();
    <a class="code" href="a00161.html#ae2e64139016744d1c8a59c4d9f6b009f" title="In Gates that were once used but are not connected now.">freeInGates</a>.pop_back();
  } <span class="keywordflow">else</span> {
    <span class="keywordtype">char</span> gateName[20];

    <span class="comment">// we will have one more in gate</span>
    ++<a class="code" href="a00161.html#ac676487d56ac68916121ce8e52465205" title="Number of in gates allocated for the nic so far.">inCnt</a>;

    <span class="comment">//get a unique name for the gate (composed of the nic module id and a counter)</span>
    sprintf(gateName, <span class="stringliteral">&quot;in%d-%d&quot;</span>, <a class="code" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109" title="module id of the nic for which information is stored">nicId</a>, <a class="code" href="a00161.html#ac676487d56ac68916121ce8e52465205" title="Number of in gates allocated for the nic so far.">inCnt</a>);

    <span class="comment">// create a new gate for the host module</span>
    cModule* <span class="keyword">const</span> pHost = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;&gt;::findHost</a>(<a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>);
    pHost-&gt;addGate(gateName, cGate::INPUT);
    hostGate = pHost-&gt;gate(gateName);

    <span class="comment">// gate of the nic</span>
    cGate *nicGate;

    <span class="comment">// create a new gate for the nic module</span>
    <a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>-&gt;addGate(gateName, cGate::INPUT);
    nicGate = <a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>-&gt;gate(gateName);

    <span class="comment">// connect the hist gate with the nic gate</span>
    hostGate-&gt;connectTo(nicGate);

    <span class="comment">// pointer to the phy module</span>
                <a class="code" href="a00053.html" title="Basic class for all physical layers, please don&#39;t touch!!">ConnectionManagerAccess</a>* phyModule;
    <span class="comment">// gate of the phy module</span>
    cGate *phyGate;

    <span class="comment">// to avoid unnecessary dynamic_casting we check for a &quot;phy&quot;-named submodule first</span>
    <span class="keywordflow">if</span> ((phyModule = dynamic_cast&lt;ConnectionManagerAccess *&gt; (<a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>-&gt;getSubmodule(<span class="stringliteral">&quot;phy&quot;</span>))) == NULL)
      phyModule = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;ConnectionManagerAccess*&gt;::findSubModule</a>(<a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>);
    assert(phyModule != 0);

    <span class="comment">// create a new gate for the phy module</span>
    phyModule-&gt;addGate(gateName, cGate::INPUT);
    phyGate = phyModule-&gt;gate(gateName);

    <span class="comment">// connect the nic gate (the gate of the compound module) to</span>
    <span class="comment">// a &quot;real&quot; gate -- the gate of the phy module</span>
    nicGate-&gt;connectTo(phyGate);
  }

  <span class="keywordflow">return</span> hostGate;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ad601c375fa2fd737f88b3a475a06ff45"></a><!-- doxytag: member="NicEntryDebug::requestOutGate" ref="ad601c375fa2fd737f88b3a475a06ff45" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cGate * NicEntryDebug::requestOutGate </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns a free out gate of the nic. </p>
<p>returns a free out gate. If none is available it is created. See NicEntry::requestInGate for a detailed description </p>

<p>References <a class="el" href="a00161.html#aac3b943e56b211541596a73f6437608a">collectFreeGates()</a>, <a class="el" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0">freeOutGates</a>, <a class="el" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109">NicEntry::nicId</a>, <a class="el" href="a00159.html#af7819e950101d5062b713eb4c182e34f">NicEntry::nicPtr</a>, and <a class="el" href="a00161.html#af1bf7c23c872e6838f8111cf58e4839e">outCnt</a>.</p>

<p>Referenced by <a class="el" href="a00161.html#af97ebc8c81c1f7d8094344d2f7fb6a17">connectTo()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <a class="code" href="a00161.html#aac3b943e56b211541596a73f6437608a" title="Iterates over all existing gates of this NicEntries nic and host and checks wether they are useable b...">collectFreeGates</a>();

  <span class="comment">// gate of the host</span>
  cGate *hostGate;

  <span class="keywordflow">if</span> (!<a class="code" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0" title="Out Gates that were once used but are not connected now.">freeOutGates</a>.empty()) {
    hostGate = <a class="code" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0" title="Out Gates that were once used but are not connected now.">freeOutGates</a>.back();
    <a class="code" href="a00161.html#a0564884c56d1bcda68b8797a5bd60af0" title="Out Gates that were once used but are not connected now.">freeOutGates</a>.pop_back();
  } <span class="keywordflow">else</span> {
    <span class="keywordtype">char</span> gateName[20];

    <span class="comment">// we will have one more out gate</span>
    ++<a class="code" href="a00161.html#af1bf7c23c872e6838f8111cf58e4839e" title="Number of out gates allocated for the nic so far.">outCnt</a>;

    <span class="comment">//get a unique name for the gate (composed of the nic module id and a counter)</span>
    sprintf(gateName, <span class="stringliteral">&quot;out%d-%d&quot;</span>, <a class="code" href="a00159.html#a35ef2f3ace25220bf226c52b444d1109" title="module id of the nic for which information is stored">nicId</a>, <a class="code" href="a00161.html#af1bf7c23c872e6838f8111cf58e4839e" title="Number of out gates allocated for the nic so far.">outCnt</a>);

    <span class="comment">// create a new gate for the host module</span>
    cModule* <span class="keyword">const</span> pHost = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;&gt;::findHost</a>(<a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>);
    pHost-&gt;addGate(gateName, cGate::OUTPUT);
    hostGate = pHost-&gt;gate(gateName);

    <span class="comment">// gate of the nic</span>
    cGate *nicGate;
    <span class="comment">// create a new gate for the nic module</span>
    <a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>-&gt;addGate(gateName, cGate::OUTPUT);
    nicGate = <a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>-&gt;gate(gateName);

    <span class="comment">// connect the hist gate with the nic gate</span>
    nicGate-&gt;connectTo(hostGate);

    <span class="comment">// pointer to the phy module</span>
    <a class="code" href="a00053.html" title="Basic class for all physical layers, please don&#39;t touch!!">ConnectionManagerAccess</a>* phyModule;
    <span class="comment">// gate of the phy module</span>
    cGate *phyGate;

    <span class="comment">// to avoid unnecessary dynamic_casting we check for a &quot;phy&quot;-named submodule first</span>
    <span class="keywordflow">if</span> ((phyModule = dynamic_cast&lt;ConnectionManagerAccess *&gt; (<a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>-&gt;getSubmodule(<span class="stringliteral">&quot;phy&quot;</span>))) == NULL)
      phyModule = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;ConnectionManagerAccess*&gt;::findSubModule</a>(<a class="code" href="a00159.html#af7819e950101d5062b713eb4c182e34f" title="Pointer to the NIC module.">nicPtr</a>);
    assert(phyModule != 0);

    <span class="comment">// create a new gate for the phy module</span>
    phyModule-&gt;addGate(gateName, cGate::OUTPUT);
    phyGate = phyModule-&gt;gate(gateName);

    <span class="comment">// connect the nic gate (the gate of the compound module) to</span>
    <span class="comment">// a &quot;real&quot; gate -- the gate of the phy module</span>
    phyGate-&gt;connectTo(nicGate);
  }

  <span class="keywordflow">return</span> hostGate;
}
</pre></div>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="a2aa0dd90daecf5469bc9c8b53b21579c"></a><!-- doxytag: member="NicEntryDebug::checkFreeGates" ref="a2aa0dd90daecf5469bc9c8b53b21579c" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="a00161.html#a2aa0dd90daecf5469bc9c8b53b21579c">NicEntryDebug::checkFreeGates</a><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Check for unknown free gates before next gate request. </p>
<p>This flag is true after creation of the <a class="el" href="a00161.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntryDebug</a> and assures that it checks for already existing in- and out-gates from a previous <a class="el" href="a00161.html" title="NicEntry is used by ConnectionManager to store the necessary information for each nic...">NicEntryDebug</a> (which can happen if the same NIC is unregistered and later again registered with a connection manager. </p>

<p>Referenced by <a class="el" href="a00161.html#aac3b943e56b211541596a73f6437608a">collectFreeGates()</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/base/connectionManager/<a class="el" href="a00252_source.html">NicEntryDebug.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/base/connectionManager/NicEntryDebug.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00161.html">NicEntryDebug</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
